home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 2002
- // Author: DRB
- //
- // Description: Get selected or sole pond fluid node
- //
-
- proc int isUsablePond( string $fluid ){
- int $solver = getAttr ($fluid + ".solver");
- if( $solver < 2 ){
- return false;
- }
- int $is2d = getAttr ($fluid + ".is2d");
- if( $is2d == 0 ){ return false; }
-
- int $heightField = getAttr ($fluid + ".heightField");
- if( !$heightField ){ return false; }
-
- int $opacityInput = getAttr ($fluid + ".opacityInput");
- if( $opacityInput != 5 ){ return false; }
-
- int $densityMethod = getAttr ($fluid + ".densityMethod");
- if( $densityMethod != 2 ){ return false; }
-
- return( true );
- }
-
- global proc string getCurrentPond()
- {
- string $fluids[] = `ls -dag -type fluidShape`;
- if( size($fluids) == 0 ){
- warning( "There are currently no ponds in this scene");
- return( "" );
- }
- // If only one fluid node, and it is suitable then use it
- if( size( $fluids ) == 1 ){
- if( isUsablePond( $fluids[0] ) ){
- return( $fluids[0] );
- } else {
- warning( "There are currently no ponds in this scene");
- return( "" );
- }
- }
-
- // There is more than one, so we need to disambiguate using the selection
- string $usablePond = "";
- int $i;
- int $moreThanOneUsable = false;
- for( $i = 0; $i < size( $fluids ); $i++ ){
- if( isUsablePond( $fluids[$i] ) ){
- if( $usablePond == "" ){
- $usablePond = $fluids[$i];
- } else {
- $moreThanOneUsable = true;
- break;
- }
- }
- }
- if( $usablePond == "" ){
- warning( "There are currently no ponds in this scene");
- return( "" );
- }
- if( !$moreThanOneUsable ){
- return( $usablePond );
- }
-
- // First check for selected fluids
- string $sel[] = `ls -sl -dag -type fluidShape`;
- if( size($sel) > 0 ){
- if( isUsablePond( $sel[0] ) ){
- return( $sel[0] );
- }
- }
- warning( "More than one suitable pond in scene.. select desired pond (fluid node) first" );
- return( "" );
- }
-